package com.xiaoxiong.mami.dao.mapper;

import com.xiaoxiong.mami.dao.daomain.Goods;
import org.apache.ibatis.jdbc.SQL;

public class GoodsSqlProvider {

    public String insertSelective(Goods record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("goods");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=BIGINT}");
        }
        
        if (record.getGoodsId() != null) {
            sql.VALUES("goodsId", "#{goodsId,jdbcType=VARCHAR}");
        }
        
        if (record.getTitle() != null) {
            sql.VALUES("title", "#{title,jdbcType=VARCHAR}");
        }
        
        if (record.getPrice() != null) {
            sql.VALUES("price", "#{price,jdbcType=DOUBLE}");
        }
        
        if (record.getGoodsDesc() != null) {
            sql.VALUES("goodsDesc", "#{goodsDesc,jdbcType=VARCHAR}");
        }
        
        if (record.getImages() != null) {
            sql.VALUES("images", "#{images,jdbcType=VARCHAR}");
        }
        
        if (record.getThumbUrl() != null) {
            sql.VALUES("thumbUrl", "#{thumbUrl,jdbcType=VARCHAR}");
        }
        
        if (record.getSort() != null) {
            sql.VALUES("sort", "#{sort,jdbcType=INTEGER}");
        }
        
        if (record.getStatus() != null) {
            sql.VALUES("status", "#{status,jdbcType=VARCHAR}");
        }
        
        if (record.getGoodsImages() != null) {
            sql.VALUES("goodsImages", "#{goodsImages,jdbcType=VARCHAR}");
        }
        
        if (record.getStock() != null) {
            sql.VALUES("stock", "#{stock,jdbcType=INTEGER}");
        }
        
        if (record.getBuyNumMax() != null) {
            sql.VALUES("buyNumMax", "#{buyNumMax,jdbcType=INTEGER}");
        }
        
        if (record.getGoodsNumber() != null) {
            sql.VALUES("goodsNumber", "#{goodsNumber,jdbcType=VARCHAR}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.VALUES("updateTime", "#{updateTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getCreateTime() != null) {
            sql.VALUES("createTime", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Goods record) {
        SQL sql = new SQL();
        sql.UPDATE("goods");
        
        if (record.getGoodsId() != null) {
            sql.SET("goodsId = #{goodsId,jdbcType=VARCHAR}");
        }
        
        if (record.getTitle() != null) {
            sql.SET("title = #{title,jdbcType=VARCHAR}");
        }
        
        if (record.getPrice() != null) {
            sql.SET("price = #{price,jdbcType=DOUBLE}");
        }
        
        if (record.getGoodsDesc() != null) {
            sql.SET("goodsDesc = #{goodsDesc,jdbcType=VARCHAR}");
        }
        
        if (record.getImages() != null) {
            sql.SET("images = #{images,jdbcType=VARCHAR}");
        }
        
        if (record.getThumbUrl() != null) {
            sql.SET("thumbUrl = #{thumbUrl,jdbcType=VARCHAR}");
        }
        
        if (record.getSort() != null) {
            sql.SET("sort = #{sort,jdbcType=INTEGER}");
        }
        
        if (record.getStatus() != null) {
            sql.SET("status = #{status,jdbcType=VARCHAR}");
        }
        
        if (record.getGoodsImages() != null) {
            sql.SET("goodsImages = #{goodsImages,jdbcType=VARCHAR}");
        }
        
        if (record.getStock() != null) {
            sql.SET("stock = #{stock,jdbcType=INTEGER}");
        }
        
        if (record.getBuyNumMax() != null) {
            sql.SET("buyNumMax = #{buyNumMax,jdbcType=INTEGER}");
        }
        
        if (record.getGoodsNumber() != null) {
            sql.SET("goodsNumber = #{goodsNumber,jdbcType=VARCHAR}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.SET("updateTime = #{updateTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getCreateTime() != null) {
            sql.SET("createTime = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        sql.WHERE("id = #{id,jdbcType=BIGINT}");
        
        return sql.toString();
    }
}